package com.qf.day15.stream;

import com.qf.day13.doudizhu.PukeCard;
import com.qf.day13.doudizhu.PukeCardUtils;

import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamDemo2 {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
        //把每个元素变为原来的平方
        System.out.println(list);
        //返回stream对象
        Stream<Integer> integerStream = list.stream().map(integer -> integer * integer);
        //integerStream的地址值
        System.out.println(integerStream);
        //转为list类型
        List<Integer> collect = integerStream.collect(Collectors.toList());
        System.out.println(collect);
        //eg2
        List<PukeCard> pukeList = PukeCardUtils.createPukeList();
        System.out.println(pukeList);
        List<String> collect1 = pukeList.stream().map(pukeCard -> pukeCard.getPoint()).collect(Collectors.toList());
        System.out.println(collect1);

    }
}
